﻿using QInfrastructure.Interfaces.SystemManager;
using QInfrastructure.Models.QueryCondition;
using QInfrastructure.Models.SystemManager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QInfrastructure.Services.SystemManager
{
    public class SystemUserService : QBaseMainService, TSystemUser
    {
        public void AddOrUpdateSysUser(SystemUser info)
        {
            
        }

        public void DeleteSysUser(Guid Id)
        {
            
        }

        public SystemUserDto LoginSubmit(SystemUserDto systemUser)
        {
            using var db=CreateContext();
            var info=db.Set<SystemUser>().Where(x=>x.UserCode==systemUser.usercode && x.UserPwd==systemUser.password).FirstOrDefault();
            if(info!=null)
            {
                systemUser.userId = info.Id;
            }
           
            return systemUser;
        }

        public List<SystemUser> GetSystemUserList()
        {
            using var db=CreateContext();
            var res=db.Set<SystemUser>().Where(x=>!x.IsDelete).ToList();
            return res;
        }

       


    }
}
